import * as Cesium from "cesium";
import SimpleLabel from '@/cesiumTools/Bubble/htmlMarker.js'

const trackPopups = []
export const renderTrackPopup =(viewer, options)=>{
    const position = Cesium.defaultValue(options.positions, {
        lng: 0,
        lat: 0,
    });
    const height = Cesium.defaultValue(options.height, 400);
    const name = Cesium.defaultValue(options.name, "站点");
    const show = Cesium.defaultValue(options.show, true);
    const color = Cesium.defaultValue(options.color, '#ff0000');
    const attr = Cesium.defaultValue(options.attr, {});
    const popupType = Cesium.defaultValue(options.type, "carPopup")
    const trackPopupController = new SimpleLabel(viewer,{
        position:Cesium.Cartesian3.fromDegrees(position.lng, position.lat, height),
        isShow:show,
        color:color,
        scaleByDistance:new Cesium.NearFarScalar(1000, 1, 20000, 0.4),
        attr:attr,
        label:name,
        popupType:popupType
    })
    const trackPopup = trackPopupController.addLabel();
    const target = {
        trackPopupController,
        trackPopup,
    }
    trackPopups.push(target)
    return target;
}